package rmi.eventing.types;

import java.text.SimpleDateFormat;

public class AuctionEvent extends Event {
	/**
	 * "AUCTION_STARTED, AUCTION_ENDED Events
	 */
	private static final long serialVersionUID = 4348276548529020464L;
	private long auctionID;
	private boolean suc=false;
	private long starttime=0;
	
	public AuctionEvent(long auctionID){
		super();
		ID = "AC"+idCounter;
		this.auctionID=auctionID;
	}
	
	
	public void setType (Type type){
		this.type=type.getValue();
	}
	public enum Type{
		AUCTION_STARTED("AUCTION_STARTED"), AUCTION_ENDED("AUCTION_ENDED");
		
		private String type;
		Type(String type){
			this.type = type;
		}
		public String getValue()
		{
		      
		      return type ;
		}
	}
	//if auction was successful
	public void setsuccess(){
		suc = true;
	}
	public int getSucc(){
		if (suc){
			return 1;
		}
		return 0;
	}
	public void setStart(long time){
		starttime= time;
	}
	public long getStartTime(){
		return starttime;
	}
	public String toString(){
		SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss z");
		String date = dateFormat.format(timestamp);
		if(type.equals("AUCTION_STARTED")){
			return "AUCTION_STARTED: "+date+" - Auction with ID "+auctionID+" has started";
		}
		else if (type.equals("AUCTION_ENDED")){
			return "AUCTION_ENDED: "+date+" - Auction with ID "+auctionID+" has ended";
		}
		return "AUCTION_EVENT: No type set";
	}

	

}
